package org.hzz.caffeine.db;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.hzz.caffeine.entity.User;

import java.util.List;

/**
 * @author 胖卡
 * @version 1.0.0
 * @date 2024/7/14
 */
@Slf4j
public class UserRepository {

    @Getter
    public static List<User> users = List.of(
            new User(1, "pkmer"),
            new User(2, "hzz"),
            new User(3, "q10viking")
    );

    public static User getById(Integer id) {
        log.info("获取user id = {}", id);
        return users.stream()
                .filter(u -> u.getId().equals(id))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("未找到用户"));
    }
}
